define(function(require,exports,module){
    var Base={
		mBaserSvrUrl:window.BaseServerUrl,
		localStorage:window.localStorage
	};
	
	function JlnRequest(){
		this.params={}
	}
	module.exports=MyFollowProxy;
function MyFollowProxy(){
	function myfollowSubmit(request, success, ignoreError) {
	    var url = Base.mBaserSvrUrl+'/myfollow';
        if (request.svr == null) request.svr = undefined;
	    if (request.token == null) request.token = undefined;
	    var content = JSON.stringify(request);
       
	    url = url + '?f=t&data=' + encodeURIComponent(content);
	    url = url + '&CallBack=?';
        $.getJSON(url,success);

	}

	function addMyFollowRq(union,userToken,relationId,relationType,remark,relationSId,success,ignoreError){
        var request=new JlnRequest();
        request.func='addMyFollow';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['rid']=relationId;
		request.params['rt']=relationType;
		request.params['r']=remark;
		request.params['rsid']=relationSId;

		if (union == true) {
	        request.svr = 'myfollow';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.addMyFollowRequest=function(userToken,relationId,relationType,remark,relationSId,success,ignoreError){
       var request= addMyFollowRq(true,userToken,relationId,relationType,remark,relationSId,success,ignoreError);
       return request;
    }
	this.addMyFollow=function(userToken,relationId,relationType,remark,relationSId,success,ignoreError){
       var request= addMyFollowRq(false,userToken,relationId,relationType,remark,relationSId,success,ignoreError);
       myfollowSubmit(request, success, ignoreError);

    }

	function cancelMyFollowRq(union,userToken,relationId,relationType,remark,relationSId,success,ignoreError){
        var request=new JlnRequest();
        request.func='cancelMyFollow';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['rid']=relationId;
		request.params['rt']=relationType;
		request.params['r']=remark;
		request.params['rsid']=relationSId;

		if (union == true) {
	        request.svr = 'myfollow';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.cancelMyFollowRequest=function(userToken,relationId,relationType,remark,relationSId,success,ignoreError){
       var request= cancelMyFollowRq(true,userToken,relationId,relationType,remark,relationSId,success,ignoreError);
       return request;
    }
	this.cancelMyFollow=function(userToken,relationId,relationType,remark,relationSId,success,ignoreError){
       var request= cancelMyFollowRq(false,userToken,relationId,relationType,remark,relationSId,success,ignoreError);
       myfollowSubmit(request, success, ignoreError);

    }

	function queryMyFollowsRq(union,userToken,relationType,isFollow,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='queryMyFollows';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['rt']=relationType;
		request.params['if']=isFollow;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'myfollow';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.queryMyFollowsRequest=function(userToken,relationType,isFollow,page,countPerPage,success,ignoreError){
       var request= queryMyFollowsRq(true,userToken,relationType,isFollow,page,countPerPage,success,ignoreError);
       return request;
    }
	this.queryMyFollows=function(userToken,relationType,isFollow,page,countPerPage,success,ignoreError){
       var request= queryMyFollowsRq(false,userToken,relationType,isFollow,page,countPerPage,success,ignoreError);
       myfollowSubmit(request, success, ignoreError);

    }

	function isFollowRq(union,userToken,relationId,relationType,relationSId,success,ignoreError){
        var request=new JlnRequest();
        request.func='isFollow';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['rid']=relationId;
		request.params['rt']=relationType;
		request.params['rsid']=relationSId;

		if (union == true) {
	        request.svr = 'myfollow';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.isFollowRequest=function(userToken,relationId,relationType,relationSId,success,ignoreError){
       var request= isFollowRq(true,userToken,relationId,relationType,relationSId,success,ignoreError);
       return request;
    }
	this.isFollow=function(userToken,relationId,relationType,relationSId,success,ignoreError){
       var request= isFollowRq(false,userToken,relationId,relationType,relationSId,success,ignoreError);
       myfollowSubmit(request, success, ignoreError);

    }
}

});
